<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\admin\model\Card as CardModel;


/**
 * 邮箱验证码接口
 */
class Card extends Api
{
    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';

    /*
     * 添加银行卡*/
    public function addCard(){
        $data=input();
        $model=new CardModel();
        $data['user_id'] = 1;
        $res = $this->validate($data, 'Card.add');
        if ($res !== true) $this->error($res, [], 500);
        if ($model->save($data)) {
            $this->success('添加成功！', [], 1);
        }
        $this->error('添加失败！', [], 500);
    }
    /***
     * 删除银行卡
     */
    public function CardDelete(){
        $model = new CardModel();
        $id = input('card_id');
        $user_id = $this->auth->id;
        $res = $model->where(['id' => $id ,'user_id' => $user_id])->update(['status'=> -1]) ;
        if ($res) {
            $this->success('删除成功！', [], 1);
        }
        $this->error('删除失败！', [], 500);
    }
}